翻訳と辞書
Words near each other
・ Covariance (disambiguation)
・ Covariance and contravariance
・ Covariance and contravariance (computer science)
・ Covariance and contravariance of vectors
・ Covariance and correlation
・ Covariance function
・ Covariance group
・ Covariance intersection
・ Covariance mapping
・ Covariance matrix
・ Covariance operator
・ Covariant classical field theory
・ Covariant derivative
・ Covariant formulation of classical electromagnetism
・ Covariant Hamiltonian field theory
Covariant return type
・ Covariant transformation
・ Covariate
・ Covariation model
・ Covario
・ Covarion
・ Covarrubias
・ Covarrubias (surname)
・ Covarrubias, Province of Burgos
・ Covas
・ Covas do Barroso
・ Covasna
・ Covasna County
・ Covasna inclined plane
・ Covasna River


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Covariant return type : ウィキペディア英語版
Covariant return type

In object-oriented programming, a covariant return type of a method is one that can be replaced by a "narrower" type when the method is overridden in a subclass. A notable language in which this is a fairly common paradigm is C++.
C# does not support return type covariance. Covariant return types have been (partially) allowed in the Java language since the release of JDK5.0, so the following example wouldn't compile on a previous release:

// Classes used as return types:

class A

class B extends A

// "Class B is more narrow than class A"
// Classes demonstrating method overriding:

class C

class D extends C

More specifically, covariant (wide to narrower) or contravariant (narrow to wider) return type refers to a situation where the return type of the overriding method is changed to a type related to (but different from) the return type of the original overridden method. The relationship between the two covariant return types is usually one which allows substitution of the one type with the other, following the Liskov substitution principle. This usually implies that the return types of the overriding methods will be subtypes of the return type of the overridden method. The above example specifically illustrates such a case. If substitution is not allowed, the return type is invariant and causes a compile error.
==See also==

* Covariance and contravariance (computer science)

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Covariant return type」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.